package com.ayf.payment.game.api.service.impl;

import com.ayf.payment.game.api.dto.ReissueAllDTO;
import com.ayf.payment.game.api.dto.criteria.ReissueAllCriteria;
import com.ayf.payment.game.api.entity.ReissueAllTask;
import com.ayf.payment.game.api.exception.ParameterException;
import com.ayf.payment.game.api.mapper.ReissueAllTaskMapper;
import com.ayf.payment.game.api.service.ReissueAllTaskService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ReissueAllTaskServiceImpl implements ReissueAllTaskService {

    @Resource
    private ReissueAllTaskMapper reissueAllTaskMapper;

    @Override
    public int save(ReissueAllTask reissueAllTask) {
        return reissueAllTaskMapper.insertSelective(reissueAllTask);
    }

    @Override
    public int update(ReissueAllTask reissueAllTask) {
        return reissueAllTaskMapper.updateByPrimaryKeySelective(reissueAllTask);
    }

    @Override
    public void delReissueAllTask(ReissueAllTask reissueAllTask) {
     Example example=new Example(ReissueAllTask.class);
        example.createCriteria().andEqualTo("merchantId",reissueAllTask.getMerchantId()).andEqualTo("id",reissueAllTask.getId());
        reissueAllTaskMapper.deleteByExample(example);
    }

    @Override
    public ReissueAllTask selectOne(String ratId) {
        return reissueAllTaskMapper.selectByPrimaryKey(ratId);
    }

    @Override
    public List<ReissueAllDTO> select(ReissueAllCriteria reissue) {
        if (reissue == null || reissue.getMerchantId() == null) {
            throw new ParameterException("没有登录");
        }
        return reissueAllTaskMapper.selectAllReissue(reissue);
    }

    @Override
    public List<ReissueAllTask> selectByTiming(ReissueAllCriteria reissue) {


        return reissueAllTaskMapper.selectByTiming(reissue);
    }
}


